<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>
<script>
    // 以函数Array为例:
    var arr = Array(1, 4, 7);
    console.log(arr);

    // 作为构造函数使用
    var arr = new Array(1, 4, 7);
    console.log(arr);



    // 距离说明:

    function Person(name, age) {
        if (this === window || this === undefined) { //作为普通函数调用
            // var err = new Error("Must be called as a constructor");
            // throw err;
            return new Person(name, age);
        } else { // 作为构造函数调用

            // {}
            // 实例化对象的原型属性     构造函数的原型对象
            // {}[[Prototype]]     =  Fn.prototype
            // this -> {}
            this.name = name;
            this.age = age;

            // return this;
        }
    }

    var p1 = Person("张三", 18); // this -> window
    console.log(p1);
    var p2 = new Person("张三", 18); // this -> 构造函数执行过程中创建的实例化对象
    console.log(p2);



</script>

</html>